package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.*;
import com.zzyl.service.CheckInService;

import com.zzyl.service.impl.CheckInServiceImpl;
import com.zzyl.vo.TasVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("checkIn")
public class CheckInController extends BaseController{

    @Resource
    private CheckInServiceImpl checkInService;

    @PostMapping("/create")
    public ResponseResult create(@RequestBody CheckInDto dto) {
//        return checkInService.createChickIn( dto,getUserIdByName());
        return checkInService.createChickIn( dto,getLoginUser());
    }

    @GetMapping
    public ResponseResult<TasVo> getTaskDetail(CheckInDetailDTO dto){
        return checkInService.getTaskDetail(dto);
    }

    @PostMapping("/review")
    @ApiOperation(value = "评估", notes = "传入入住对象")
    public ResponseResult review(
            @RequestBody @ApiParam(value = "入住对象", required = true) ReviewDTO reviewDTO) {
        log.info("{}",reviewDTO);
        return checkInService.review(reviewDTO,getLoginUser());
    }

    @PutMapping("submit")
    public ResponseResult agree(AgreeDTO dto){
        return checkInService.agree(dto,getLoginUser());
    }
    @PutMapping("/reject")
    public ResponseResult auditReject(AgreeDTO dto) {
        return checkInService.reject(dto,getLoginUser());
    }

    @PutMapping
    public ResponseResult disapprove(
            @RequestParam @ApiParam(value = "入住Id") Long id,
            @RequestParam @ApiParam(value = "驳回消息") String message,
            @RequestParam @ApiParam(value = "任务Id") String taskId) {
        return checkInService.disapprove(id, message, taskId, getLoginUser());
    }

    @PostMapping
    public ResponseResult checkIn(@RequestBody CheckInConfigDTO dto) {
        log.info("传过来的={}",dto);
        return checkInService.checkIn(dto,getLoginUser());
    }

}
